package com.itheima.d02;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Test {
    public static void main(String[] args) {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(2);
    service.schedule(()->{
        int sum=0;
        for (int i = 0; i < 100; i++) {
            sum+=i;
            System.out.println("累加" + i);
        }
        System.out.println(sum);
        }, 10, TimeUnit.SECONDS);
}
    }

